<html
        lang="zh"
        xmlns:th="http://www.thymeleaf.org"
        xmlns:shiro="http://www.pollix.at/thymeleaf/shiro"
>
<head>
    <th:block th:insert="~{include :: header('设备遥测数据详情')}"/>
    <style>
        .detail-box {
            padding: 20px;
            border: 1px solid #e6e6e6;
            border-radius: 5px;
            background-color: #f9f9f9;
        }
        .detail-item {
            margin-bottom: 15px;
            padding-bottom: 15px;
            border-bottom: 1px solid #e6e6e6;
        }
        .detail-item:last-child {
            border-bottom: none;
            margin-bottom: 0;
            padding-bottom: 0;
        }
        .detail-label {
            font-weight: bold;
            color: #333;
            width: 120px;
            display: inline-block;
        }
        .detail-value {
            margin-left: 10px;
            word-break: break-all;
        }
        .data-content {
            background-color: #fff;
            padding: 15px;
            border-radius: 4px;
            border: 1px solid #ddd;
            max-height: 400px;
            overflow-y: auto;
            font-family: 'Courier New', monospace;
            font-size: 14px;
            white-space: pre-wrap;
        }
    </style>
</head>
<body class="gray-bg">
<div class="container-div">
    <div class="row">
        <div class="col-sm-12">
            <div class="detail-box">
                <div class="detail-item">
                    <span class="detail-label">记录ID：</span>
                    <span class="detail-value" th:text="${devTelemetryData.id}"></span>
                </div>
                <div class="detail-item">
                    <span class="detail-label">设备ID：</span>
                    <span class="detail-value" th:text="${devTelemetryData.deviceId}"></span>
                </div>
                <div class="detail-item">
                    <span class="detail-label">接收时间：</span>
                    <span class="detail-value" th:text="${#dates.format(devTelemetryData.receiveTime, 'yyyy-MM-dd HH:mm:ss')}"></span>
                </div>
                <div class="detail-item">
                    <span class="detail-label">遥测数据：</span>
                    <div class="detail-value">
                        <div class="data-content" th:text="${#strings.replace(#strings.replace(#strings.replace(#strings.toString(devTelemetryData.data), '\r\n', ''), '\n', ''), '\t', '')}"></div>
                    </div>
                </div>
            </div>
        </div>
    </div>
</div>

<th:block th:insert="~{include :: footer}"/>
<script th:inline="javascript">
    $(function() {
        // 尝试格式化JSON数据
        var dataContent = $('.data-content');
        var dataText = dataContent.text();
        
        try {
            // 尝试解析JSON
            var parsedData = JSON.parse(dataText);
            // 格式化显示
            var formattedData = JSON.stringify(parsedData, null, 2);
            dataContent.text(formattedData);
        } catch (e) {
            // 不是JSON，保持原样
        }
    });
</script>
</body>
</html>